package bluetooth;

import android.accessibilityservice.AccessibilityService;
import android.app.Notification;
import android.app.PendingIntent;
import android.os.Build;
import android.os.Handler;
import android.text.TextUtils;
import android.view.accessibility.AccessibilityEvent;
import android.widget.Toast;

import java.util.List;

public class WeChatAccessibilityService extends AccessibilityService {

    @Override
    public void onAccessibilityEvent(AccessibilityEvent event) {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(WeChatAccessibilityService.this,"---",Toast.LENGTH_SHORT).show();

            }
        },100);

        if (Build.VERSION.SDK_INT < 18) {
//            Notification notification = (Notification) event.getParcelableData();
//            List<String> textList = getText(notification);
//            if (textList != null && textList.size() > 0) {
//                for (String text : textList) {
//                    if (!TextUtils.isEmpty(text) &&
//                            text.contains("[微信红包]")) {
//                        final PendingIntent pendingIntent = notification.contentIntent;
//                        try {
//                            if (pendingIntent != null) {
//                                pendingIntent.send();
//                            }
//                        } catch (PendingIntent.CanceledException e) {
//                            e.printStackTrace();
//                        }
//                    }
//                    break;
//                }
//            }
        }
    }

    @Override
    public void onInterrupt() {

    }

}
